Text flow in and around irregular containers

ABSTRACT

Providing text flow in or around an irregular container, such as a non-rectangular graphic, is disclosed. In the case of flow around a container, the intersection, if any, between a proposed text rectangle and the irregular container is determined. A valid rectangle, if any, that is not within the bounds in the x-direction of an area of intersection between the proposed text rectangle and the graphic is identified as a valid text area within the proposed text rectangle. In the case of flow around a container, one or more difference areas, if any, in which a proposed text rectangle is present but the container is not present are found. A valid rectangle, if any, that is not within the bounds in the x-direction of any of said one or more difference areas is identified as a valid text area within the proposed text rectangle.

CROSS REFERENCE TO OTHER APPLICATIONS

This application is a continuation of co-pending U.S. patent applicationSer. No. 11/329,385, entitled TEXT FLOW IN AND AROUND IRREGULARCONTAINERS, filed Jan. 9, 2006 which is incorporated herein by referencefor all purposes.

BACKGROUND OF THE INVENTION

Creators of text-containing documents sometimes desire to set off aportion of text from other text appearing on a page, for example toinclude a vignette, background information, a quotation, or otherinformation related to a topic that is the subject of other text on thepage. In a typical word processing application, a user can define arectangular text box within (e.g., overlaying) an irregularly shapedcontainer, e.g., a geometric or other shape that is not a square orother rectangle, and enter text within the rectangular text box.However, depending on the shape of the container this approach may notmaximize the use of space within the container and may not provide avisual effect desired by the creator of the document, e.g., having thetext inside the container more closely follow the contours of thecontainer.

On some occasions, a creator of a text document may wish to incorporateon the page an irregularly shaped graphic or other object, such as anirregular container containing text, and have text flow around thegraphic or other object. In a typical word processing application, agraphic or other object may be incorporated into a page and text made toflow around a rectangular box defined to block out space on the page forthe graphic or other object. However, depending on the shape of thecontainer this approach may not maximize the use of space on the pageand may not provide a visual effect desired by the creator of thedocument, e.g., having the text outside the container more closelyfollow the contours of the container.

Therefore, there is a need for a way to provide text flow in and aroundirregular containers that enables text to conform more closely to theshape of an irregular container.

BRIEF DESCRIPTION OF THE DRAWINGS

Various embodiments of the invention are disclosed in the followingdetailed description and the accompanying drawings.

FIGS. 1A and 1B illustrate an embodiment of a process for providing textflow around an irregular container.

FIGS. 2A and 2B illustrate an embodiment of a process for providing textflow within an irregular container.

FIG. 3 is a flow chart illustrating an embodiment of a process forproviding text flow within and/or around an irregular container or othergraphic.

FIG. 4 is a flow chart illustrating an embodiment of a process fordetermining valid text areas within and/or around an irregular containeror other graphic.

FIG. 5 is a flow chart illustrating an embodiment of a process fordefining an exclusion polygon that optionally provides a margin betweena container and text that flows around and/or within the container.

FIGS. 6A-7B illustrate an example of the process of FIG. 5 as applied toa container in the shape of a trapezoid.

FIG. 8 is a flow chart illustrating an embodiment of a process forlooking ahead to find a next proposed text rectangles that includesvalid text areas.

DETAILED DESCRIPTION

The invention can be implemented in numerous ways, including as aprocess, an apparatus, a system, a composition of matter, a computerreadable medium such as a computer readable storage medium or a computernetwork wherein program instructions are sent over optical or electroniccommunication links. In this specification, these implementations, orany other form that the invention may take, may be referred to astechniques. A component such as a processor or a memory described asbeing configured to perform a task includes both a general componentthat is temporarily configured to perform the task at a given time or aspecific component that is manufactured to perform the task. In general,the order of the steps of disclosed processes may be altered within thescope of the invention.

A detailed description of one or more embodiments of the invention isprovided below along with accompanying figures that illustrate theprinciples of the invention. The invention is described in connectionwith such embodiments, but the invention is not limited to anyembodiment. The scope of the invention is limited only by the claims andthe invention encompasses numerous alternatives, modifications andequivalents. Numerous specific details are set forth in the followingdescription in order to provide a thorough understanding of theinvention. These details are provided for the purpose of example and theinvention may be practiced according to the claims without some or allof these specific details. For the purpose of clarity, technicalmaterial that is known in the technical fields related to the inventionhas not been described in detail so that the invention is notunnecessarily obscured.

Text flow in and around irregular containers is disclosed. In someembodiments, text flow around an irregular container includes findingthe intersection, if any, between a proposed text rectangle and theirregular container and identifying as a valid text area within theproposed text rectangle a valid rectangle, if any, that is not withinthe bounds in the x-direction of an area of intersection between theproposed text rectangle and the graphic. In some embodiments, text flowwithin an irregular container includes finding one or more differenceareas, if any, in which a proposed text rectangle is present but thecontainer is not present and identifying as a valid text area within theproposed text rectangle a valid rectangle, if any, that is not withinthe bounds in the x-direction of any of said one or more differenceareas.

FIGS. 1A and 1B illustrate an embodiment of a process for providing textflow around an irregular container. In the example shown, a rectangle102 has been proposed to contain text intended to flow around anirregularly shaped container (or graphic) 104. In FIG. 1A areas ofintersection between the rectangle 102 and container 104 are crosshatched. As shown in FIG. 1B, in some embodiments, the bounds of theareas of intersection—in this example the bounding rectangles ABKL,CDIJ, and EFGH—in the x-direction are determined and excluded (i.e.,subtracted) from the original proposed text rectangle. In someembodiments, the bounding rectangles are determined, sorted into anorder, e.g., by minimum “x” axis coordinate, and adjacent and/oroverlapping bounding rectangles are combined, after which the sorted and(if applicable) combined bounding rectangles are excluded (i.e.,subtracted) from the originally proposed text rectangle. In someembodiments, adjacent or successive holes that are not touching oroverlapping but are determined to be within a threshold distance of eachother in the x-direction are combined, e.g., to avoid identifying as avalid text area an area that is not wide enough to include a meaningfulamount of text. The excluded rectangles, or “holes”, are used todetermine remaining valid text rectangles BCJK and DEHI in which in thisexample text flowing around the container 104 may be included. In someembodiments, the rectangle 102 is proposed by a text system portion of aword processing or other application to a text flow (sometimes referredto herein as a “text wrapper”) portion of the word processing or otherapplication. In some embodiments, the text flow portion receives fromthe text system portion a proposed rectangle such as proposed textrectangle 102 and an indication of whether text is intended to flowwithin or around the intersecting irregular container (or othergraphic), and the text flow portion returns to the text system the validrectangles, if any, included in the proposed rectangle, in this examplerectangles BCJK and DEHI.

FIGS. 2A and 2B illustrate an embodiment of a process for providing textflow within an irregular container. In this example, the differencebetween the proposed rectangle 102 and the irregular container 104(i.e., the area rectangle-not-container) is shown cross hatched. In someembodiments, the bounds of the difference areas, in this example thebounding rectangles MNQR and OFGP, are determined and subtracted fromthe originally proposed rectangle 102 to determine and return valid textrectangles AMRL and NOPQ. In this example, the right-most overlappingportion of the container 104, included in the area bounded by OFGP, isexcluded because no part of that portion has sufficient height in they-direction to have text rendered without exceeding the bounds of thecontainer and/or with prescribed line spacing, etc.

FIG. 3 is a flow chart illustrating an embodiment of a process forproviding text flow within and/or around an irregular container or othergraphic. At 302, a proposed rectangle is received. At 304, any validtext area(s), e.g., rectangle(s) within the proposed rectangle receivedat 302 are determined and returned. In various embodiments, the validareas are determined as described above in connection with FIGS. 1A-2B,as applicable, e.g., depending on whether text is to flow within oraround the irregular container or other graphic.

FIG. 4 is a flow chart illustrating an embodiment of a process fordetermining valid text areas within and/or around an irregular containeror other graphic. In some embodiments, 304 of FIG. 3 includes theprocess of FIG. 4. After receiving a proposed rectangle (402), it isdetermined at 404 whether text is to flow around or inside a containerthat intersects with the proposed rectangle. In some embodiments, a textsystem or other process or module that proposes the text rectangle,e.g., to a text flow and/or wrapping process or module, sets a flag orother data value that indicates whether text is to flow inside or aroundthe container. In some embodiments, the text system is configured torecognize when a proposed text rectangle, e.g., for a next line of text,overlaps with a container around or within which text is to flow andsends the proposed rectangle to the text flow and/or wrapping module todetermine which portion(s), if any, of the proposed rectangle are validto be used. If the text for which the proposed rectangle was proposed isto flow inside the container, at 406 the bounds of the areas in whichthe proposed rectangle “B” but not the container “A” are present (i.e.,the difference obtained by subtracting from the proposed rectangle areasin which the container overlaps it) are determined and considered to be“holes” within which text cannot be included. If text for which theproposed rectangle was proposed is to flow around the container, at 408the bounds of the areas of intersection (overlap) of the container “A”and the proposed rectangle “B” are determined and considered to be“holes” within which text cannot be included. At 410, the “holes”determined at 406 or 408, as applicable, are used to define positiveareas, i.e., valid rectangles, if any, within which text may beincluded, and the valid rectangle(s), if any, are returned at 412. Insome embodiments, 406 and/or 408, as applicable, include sorting holesby minimum x and merging overlapping and adjacent holes. In someembodiments, a container or other graphic is described as a Bezier pathand holes are identified in 406 and/or 408, as applicable, in part bydetermining a polygon that approximates the Bezier path, and then usinga publicly-available software tool, such as Alan Murta's General PolygonClipper described and available via the Internet atwww.cs.man.ac.uk/˜toby/alan/software/, to determine the intersectionand/or difference, as applicable, between the proposed rectangle and thecontainer.

FIG. 5 is a flow chart illustrating an embodiment of a process fordefining an exclusion polygon that optionally provides a margin betweena container and text that flows around and/or within the container. At502 a container is received. In some embodiments, 502 includes receivingvia a user interface a selection from a menu of predefined containers.In some embodiments, 502 includes generating and/or updating a Bezierpath describing the container. In some embodiments, a user may defineand/or change the shape and/or size of the container via well known userinterfaces, such as a drawing tool or changing the size or relativedimensions of a bounding box, outline, or other display or interfacehaving such controls and/or functionality. At 504, it is determinedwhether text is to flow inside the container, around the container, orboth. At 506, for determining valid text areas inside the container,including an allowance for an inside margin, an inclusion polygon to beused to determine valid text areas inside the container, e.g., as in 406and 410 of FIG. 4, is determined by subtracting from the originalcontainer shape a set of inside margin shapes superimposed on theoriginal container. In some embodiments, 506 includes defining a polygonthat at least approximates an original container described originally asa Bezier path, defining for each side of the polygon a rectangle that istwice as wide as the desired inside margin, encloses the side, and isbisected by the side; defining for each vertex of the polygon a circleof radius equal to the desired inside margin centered on the vertex; andsubtracting from the polygon that at least approximates the originalcontainer areas of overlap between the above-described rectangles andcircles, referred herein and in FIG. 5 as “inside margin shapes”.

At 508, for determining valid text areas around the container, includingan allowance for an outside margin, an exclusion polygon to be used todetermine valid areas for text to flow around the container, e.g., as in408 and 410 of FIG. 4, is determined by uniting with the originalcontainer shape a set of outside margin shapes superimposed on theoriginal container. In some embodiments, 508 includes defining a polygonthat at least approximates an original container described originally asa Bezier path, defining for each side of the polygon a rectangle that istwice as wide as the desired outside margin, encloses the side, and isbisected by the side; defining for each vertex of the polygon a circleof radius equal to the desired outside margin centered on the vertex;and using the union of the polygon that at least approximates theoriginal container and the above-described rectangles and circles,referred herein and in FIG. 5 as “outside margin shapes”, as anexclusion polygon to be used to determine “holes” in a proposedrectangle, as in 408 and 410 of FIG. 4. It is noted that if the insideand outside margins are the same, the inside margin shapes and theoutside margin shapes are likewise the same and in some embodiments theprocessing described in connection with 506 and 508 for defining themargin shapes is performed only once. In some embodiments, the inclusionpolygon determined in 506 and/or the exclusion polygon determined in 508is described and/or at least approximated by a polygon, e.g., to enablethe General Polygon Clipper or a similar software tool to be used toperform clipping operations (e.g., intersection, difference/subtraction)between a proposed text rectangle and the inclusion and/or exclusionpolygon, as applicable.

FIGS. 6A-7B illustrate an example of the process of FIG. 5 as applied toa container in the shape of a trapezoid. FIG. 6A shows an irregularcontainer 602 in the shape of a trapezoid. FIG. 6B shows the container602, in dashed lines, enclosed by a set of margin shapes comprisingrectangles 604-610 and circles 612-618. In this example, the width ofrectangles 604-610 is twice the desired inside and/or outside margin, asapplicable, and the radius of each of the circles 612-618 is equal tothe applicable desired margin. In various embodiments, the margin isexpressed as a number of typeset points, in inches or other units ofmeasure, and/or otherwise.

FIG. 7A shows an exclusion shape 710 determined, as in 508, by findingthe union of the margin shapes 604-618 of FIG. 6 and the originalcontainer 602, the latter being shown in FIG. 7A in dashed lines forreference. As noted above, while the exclusion shape 710 as shown inFIG. 7A has rounded corners, in some embodiments the shape 710 is atleast approximated by a polygon (e.g., one using a series of short sidesto approximate the rounded corners shown in FIG. 7A) and this exclusionpolygon is used to define “holes” to be excluded from a proposed textrectangle. In some embodiments, valid areas for text to flow aroundcontainer 602, if any, would be determined in this example byconsidering as holes the bounds of areas of intersection between aproposed text rectangle and the exclusion shape 710 and using the holesto determine and return positive areas, if any, in which text to flowaround the container 602 may be included.

FIG. 7B shows an inclusion shape 720 determined by subtracting marginshapes 604-618 from the original container 602, the latter being shownin FIG. 7B in dashed lines for reference. In some embodiments, if theinclusion shape 720 had rounded corners, the shape 720 would be at leastapproximated by a polygon (e.g., one using a series of short sides toapproximate any rounded corners) and this inclusion polygon would beused to find valid text areas, if any, within a proposed text rectangle.In some embodiments, valid areas for text to flow within container 602,if any, would be determined in this example by considering as holes thebounds of areas of difference between a proposed text rectangle and theinclusion shape 720 and using the holes to determine and return positiveareas, if any, in which text to flow within the container 602 may beincluded.

In some embodiments, a text system or other process or module configuredto generate (proposed) text rectangles is configured to respond to anindication that a first proposed text rectangle has no valid text areasfor text to flow around and/or within a container, as applicable, byproposing a next proposed text rectangle that is one pixel lower in they-direction than the first proposed text rectangle. In this way, text isincluded at the first (highest in the y-direction) possible position.However, in some cases a container may have a shape such that theabove-described approach of advancing pixel-by-pixel results in needlesssuccessive cycles of proposing text rectangles on the part of the textsystem or other process or module and processing proposed textrectangles to determine and return a null result on the part of the textflow or wrapping process or module, with concomitant loss of time andcomputing resources. In some embodiments, this potential inefficiency isavoided by configuring the text flow or wrapping process or module tolook ahead, in various embodiments either pixel-by-pixel, e.g., up to aprescribed and/or configurable limit, or by skipping ahead a prescribedand/or configurable number of pixels and/or a distance determined byapplying a “look ahead” algorithm, to find and return to the text systema place marker (e.g., a y-direction location) to be used to propose atext rectangle that has been pre-determined to include at least onevalid text area. In some embodiments, for flow around an irregularcontainer the following look ahead algorithm is used if there are novalid rectangles in a proposed text rectangle: 1) extend the bottom ofthe proposed rectangle to the bottom of the irregular shape; 2) unitethe irregular shape with the extended rectangle; 3) subtract theoriginal irregular shape and the original proposed rectangle from theunion; and 4) if the result is empty (i.e., no resulting shape is leftafter subtracting the original irregular shape and the original proposedrectangle, e.g., because the extended rectangle is enclosed within theunion of the original irregular shape and the original proposedrectangle), skip ahead in the y-direction by a distance D equal to thebottom of the extended rectangle minus the bottom of the originalproposed text rectangle, otherwise (i.e., if the result of subtractingthe original irregular shape from the union of the extended rectanglewith the original irregular shape and the original proposed textrectangle is not empty) skip ahead a distance D equal to the top of theshape derived in step 3 minus the bottom of the original proposed textrectangle. In some embodiments, the text flow or wrapping process ormodule treats the next valid proposed text rectangle as having beenproposed and returns as valid rectangles the valid portions of theproposed rectangle found by looking ahead as described above.

FIG. 8 is a flow chart illustrating an embodiment of a process forlooking ahead to find a next proposed text rectangles that includesvalid text areas. In 802, an indication is received, e.g., by a textflow or wrapping process or module, that there are no valid text areasin a received proposed text rectangle. At 804, the text flow or wrappingprocess or module advances the proposed rectangle by ten pixels in they-direction. At 806 it is determine whether the advanced proposed textrectangle includes any valid text area. In some embodiments, 806includes performing a difference and/or intersection operation, asapplicable, determining whether the result is a hole coextensive withthe advanced proposed rectangle, and if so concluding the advancedproposed rectangle includes no valid text area. In some embodiments,complete processing, e.g., as in FIG. 4, is performed for each iterationof 804-806. Once a proposed rectangle that includes at least one validtext area is found, at 808 a place marker or other data identifying thenext valid proposed rectangle and/or in some embodiments any associatedvalid text areas are returned. In some alternative embodiments, theprocess of FIG. 8 advances pixel-by-pixel, in some embodiments up to aprescribed limit, until a proposed text rectangle that includes at leastone valid text area is found, instead of skipping ahead as in 804.

Although in certain of the embodiments described above an “irregular”container is referred to, the techniques described herein are suitablefor providing text flow in and/or around containers of any arbitraryshape, whether regular or not.

Although the foregoing embodiments have been described in some detailfor purposes of clarity of understanding, the invention is not limitedto the details provided. There are many alternative ways of implementingthe invention. The disclosed embodiments are illustrative and notrestrictive.

1. A method for providing text flow around a non-rectangular graphic,comprising: using a processor to find an intersection, if any, between aproposed text rectangle and the graphic; using the processor todetermine a bounding rectangle of the intersection; and using theprocessor to identify as a valid text area within the proposed textrectangle a valid rectangle, if any, that does not include the boundingrectangle or any portion thereof.
 2. A method as recited in claim 1,wherein the graphic comprises a Bezier or other curve and finding theintersection, if any, between a proposed text rectangle and the graphicincludes determining a polygon that at least approximates the graphic.3. A method as recited in claim 1, wherein identifying as a valid textarea within the proposed text rectangle a valid rectangle, if any, thatis not within the bounds in the x-direction of an area of intersectionbetween the proposed text rectangle and the graphic is includesdetermining the bounds in the x-direction of each area of intersectionand considering each such area of intersection to be a hole within whichtext may not be included.
 4. A method as recited in claim 1, whereinidentifying as a valid text area within the proposed text rectangle avalid rectangle, if any, that is not within the bounds in thex-direction of an area of intersection between the proposed textrectangle and the graphic includes identifying each such valid textarea, if any.
 5. A method as recited in claim 1, wherein identifying asa valid text area within the proposed text rectangle a valid rectangle,if any, that is not within the bounds in the x-direction of an area ofintersection between the proposed text rectangle and the graphicincludes: sorting two or more areas of intersection by their respectiveminimum x-coordinates; combining overlapping or adjacent areas ofintersection; and using the sorted and combined, if applicable, areas ofintersection to find any valid text areas.
 6. A method as recited inclaim 1, wherein the graphic comprises an exclusion polygon determinedby uniting with an original graphic a set of margin shapes calculated toextend the outer boundary of the original graphic by an amount equal toa desired margin between text flowing around the graphic, on the onehand, and the original graphic as and when rendered on the page, on theother hand.
 7. A method as recited in claim 6, further includingdefining the margin shapes.
 8. A method as recited in claim 7, whereindefining the margin shapes includes defining for each side of a polygonthat at least approximates the graphic a rectangle that is twice as wideas the desired margin, encloses the side, and is bisected by the side;and defining for each vertex of the polygon that at least approximatesthe graphic a circle centered on the vertex and having a radius equal tothe desired margin.
 9. A method as recited in claim 1, furthercomprising, in the event no valid text area is found, looking ahead byadvancing the proposed text rectangle by one or more pixels in they-direction and determining whether the advanced proposed text rectangleincludes a valid text area.
 10. A method as recited in claim 1, furthercomprising determining a respective bounding rectangle for each of a setof one or more intersections between the proposed text rectangle and thegraphic and combining any bounding rectangles that are within athreshold distance of each other.
 11. A method as recited in claim 1,further comprising returning as a valid text area only those validrectangles, if any, that exceed a prescribed minimum size.
 12. A methodfor providing text flow within a non-rectangular container, comprising:using a processor to find a difference area, if any, in which a proposedtext rectangle is present but the container is not present; using theprocessor to determine a bounding rectangle for the difference area; andusing the processor to identify as a valid text area within the proposedtext rectangle a valid rectangle, if any, that does not include thebounding rectangle or any portion thereof.
 13. A method as recited inclaim 12, wherein the container comprises an inclusion polygondetermined by subtracting from an original graphic a set of marginshapes calculated to reduce an outer boundary of the original graphic byan amount equal to a desired margin between text flowing within thecontainer, on the one hand, and the original graphic as and whenrendered on the page, on the other hand.
 14. A method as recited inclaim 12, wherein identifying as a valid text area within the proposedtext rectangle a valid rectangle, if any, that is not within the boundsin the x-direction of any of said one or more difference areas includesdetermining the bounds in the x-direction of each difference area andconsidering each such difference area to be a hole within which text maynot be included.
 15. A method as recited in claim 12, further comprisingreceiving a Bezier path describing the container and determining apolygon that at least approximates the Bezier path.
 16. A method asrecited in claim 12, wherein a polygon clipper software tool is used tofind the one or more difference areas, if any, in which the proposedtext rectangle is present but the container is not present.
 17. A methodas recited in claim 12, further including receiving the proposed textrectangle from a text system, process, or module.
 18. A system forproviding text flow around a non-rectangular graphic, comprising: aprocessor configured to find an intersection, if any, between a proposedtext rectangle and the graphic; determine a bounding rectangle of theintersection; and identify as a valid text area within the proposed textrectangle a valid rectangle, if any, that does not include the boundingrectangle or any portion thereof; and a memory configured to provideinstructions to the processor.
 19. A system as recited in claim 18,wherein comprises a Bezier or other curve and finding the intersection,if any, between a proposed text rectangle and the graphic includesdetermining a polygon that at least approximates the graphic.
 20. Acomputer program product for providing text flow around anon-rectangular graphic, the computer program product being embodied ina computer readable medium and comprising computer instructions for:finding an intersection, if any, between a proposed text rectangle andthe graphic; determining a bounding rectangle of the intersection; andidentifying as a valid text area within the proposed text rectangle avalid rectangle, if any, that does not include the bounding rectangle orany portion thereof.